package com.ffox.controller;

import com.ffox.result.Result;
import com.ffox.service.SchoolLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 学校登录控制器
 */
@RestController
@RequestMapping("/login")
public class SchoolLoginController {

    @Autowired
    private SchoolLoginService schoolLoginService;

    /**
     * 学校登录接口
     *
     * @param number   学校账号
     * @param password 学校密码
     * @return 登录结果
     */
    @PostMapping("/schoolLogin")
    public Result<Map<String, Object>> schoolLogin(@RequestParam String number, @RequestParam String password) {
        return schoolLoginService.schoolLogin(number, password);
    }

    /**
     * 学校注册接口
     *
     * @param number        学校账号
     * @param password      学校密码
     * @param mobile        联系电话
     * @param detailAddress 详细地址
     * @return 注册结果
     */
    @PostMapping("/schoolInsert")
    public Result<Integer> schoolInsert(@RequestParam String number, @RequestParam String password, @RequestParam Integer districtCode, @RequestParam String realName, @RequestParam String mobile, @RequestParam String province , @RequestParam String city, @RequestParam String district, @RequestParam String detailAddress) {
        return schoolLoginService.schoolInsert(number, password, String.valueOf(districtCode), realName, mobile, province, city, district, detailAddress);
    }

    /**
     * 学校删除接口
     *
     * @param id 学校ID
     * @return 删除结果
     */
    @PostMapping("/schoolDelete/{id}")
    public Result<Integer> schoolDelete(@PathVariable("id") Long id) {
        return schoolLoginService.schoolDelete(id);
    }
}
